{include file="user.header.html"}
{$build_editor}
{$build_upload}
<div id="main" class="clearfix"> {include file="user.menu.html"}
  <div id="right"> {include file="user.curlocal.html"}
    <div class="wrapful">{include file="user.submenu.html"}
      <div  class="wrap">
        <div class="public">
          <form method="post" id="navigation_form" enctype="multipart/form-data">
            <div id="warning"></div>
            <ul class="info_table">
              <li>
                <h4>{$lang.title}:</h4>
                <p>
                  <input type="text" class="text width_normal" name="title" value="{$navigation.title|escape}" />
                </p>
              </li>
              <li>
                <h4>{$lang.if_show}:</h4>
                <p>{html_radios options=$yes_or_no checked=$navigation.if_show name=if_show}</p>
              </li>
              <li>
                <h4>{$lang.sort_order}:</h4>
                <p>
                  <input type="text" class="text width_short" name="sort_order" value="{$navigation.sort_order}"/>
                </p>
              </li>
              <li>
                <h4>{$lang.content}:</h4>
              </li>
            </ul>
            <div class="editor" style="margin-left:118px; margin-top:-23px;width:714px;">
              <div>
                <textarea name="description" id="description" style="width:713px; height:400px;">{$navigation.description|escape}</textarea>
              </div>
              <div class="multimage-wrapper descimage-wrapper">
                <ul class="multimage-tabs clearfix">
                  <li class="selected">插入描述图片</li>
                </ul>
                <div class="multimage-panels clearfix">
                  <div class="upload_btn">
                    <div class="btn-upload-image"><b class="hide EDITOR_SWFU_filePicker"></b></div>
                  </div>
                  <div class="text">{$lang.note_for_upload}</div>
                </div>
                <div class="multimage-piclist clearfix">
                  <ul id="desc_images" class="preview J_descriptioneditor">
                    <!--{foreach from=$navigation.desc_images item=image}-->
                    <li ectype="handle_pic" file_type="{$image.file_type}" file_name="{$image.file_name|escape}" file_path="{$image.file_path|url_format}" file_id="{$image.file_id}">
                      <input type="hidden" name="file_id[]" value="{$image.file_id}">
                      <div class="pic"> <img src="{$image.file_path|url_format}" width="80" height="80" alt="{$image.file_name|escape}" title="{$image.file_name|escape}" /> </div>
                      <div ectype="handler" class="bg">
                        <p class="operation"> <a class="cut_in" ectype="insert_editor" href="javascript:void(0);" ecm_title="{$lang.insert_editor}"></a> <span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span> </p>
                      </div>
                    </li>
                    <!--{/foreach}-->
                  </ul>
                </div>
                <div class="notice-word {if !$navigation.desc_images}hidden{/if}" style="padding:14px;">
                  <p class="yellow">插入方法：将鼠标移至需要插入的图片上面，然后点击插入按钮，即可将图片插入到编辑器中。</p>
                </div> 
              </div>
              <div class="clear"></div>
            </div>
            <div class="issuance" style="margin:40px 0 0 118px;">
              <input type="submit" class="btn" value="{$lang.submit}" />
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$(function(){
    trigger_uploader();
    $('#navigation_form').validate({
        errorLabelContainer: $('#warning'),
        invalidHandler: function(form, validator) {
           var errors = validator.numberOfInvalids();
           if(errors)
           {
               $('#warning').show();
           }
           else
           {
               $('#warning').hide();
           }
        },
        rules : {
            title : {
                required   : true
            },
            sort_order : {
                number     : true
            }
        },
        messages : {
            title  : {
                required   : '{$lang.title_empty}'
            },
            sort_order : {
                number    : '{$lang.number_only}'
            }
        }
    });
});
function add_uploadedfile(file_data)
{
  $('#desc_images').parent().next('.notice-word').show();
	$('#desc_images').append('<li style="z-index:4" file_type="'+file_data.file_type+'" file_name="'+ file_data.file_name +'" file_path="'+ url_format(file_data.file_path) +'" ectype="handle_pic" file_id="'+ file_data.file_id +'"><input type="hidden" name="desc_file_id[]" value="'+ file_data.file_id +'"><div class="pic" style="z-index: 2;"><img src="'+ url_format(file_data.file_path) +'" width="80" height="80" alt="'+ file_data.file_name +'" /></div><div ectype="handler" class="bg" style="z-index: 3;display:none"><p class="operation"><a href="javascript:void(0);" class="cut_in" ectype="insert_editor" ecm_title="{$lang.insert_editor}"></a><span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span></p></div></li>');
	trigger_uploader();
 	if(EDITOR_SWFU.getStats().progressNum == 0){
   		window.setTimeout(function(){
         	$('#editor_uploader').css('opacity', 0);
			$('*[ectype="handle_pic"]').css('z-index', 999);
     	},5000);
 	}
}
function drop_image(file_id)
{
	layer.open({ content:lang.uploadedfile_drop_confirm, btn:[lang.confirm, lang.cancel],
		yes:function(index){
			$.getJSON("{url route='my_navigation/deleteimage'}", { id:file_id}, function(data) {
				if (data.done){
					$('*[file_id="' + file_id + '"]').remove();
				} else {
					layer.msg(data.msg);
				}
				layer.close(index);
			});
		},
		no: function(index) {
			layer.close(index);
		}
	});			
}
</script> 
{include file="user.footer.html"}